package com.ruoyi.lmisBaseManage;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.lmisBaseManage.domain.LmisCage;
import com.ruoyi.lmisBaseManage.service.ILmisCageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 笼位管理Controller
 * 
 * @author wj
 * @date 2025-08-13
 */
@RestController
@RequestMapping("/lmisCage/cage")
public class LmisCageController extends BaseController
{
    @Autowired
    private ILmisCageService lmisCageService;

    /**
     * 查询笼位管理列表
     */
    @PreAuthorize("@ss.hasPermi('lmisCage:cage:list')")
    @GetMapping("/list")
    public TableDataInfo list(LmisCage lmisCage)
    {
        startPage();
        List<LmisCage> list = lmisCageService.selectLmisCageList(lmisCage);
        return getDataTable(list);
    }

    /**
     * 导出笼位管理列表
     */
    @PreAuthorize("@ss.hasPermi('lmisCage:cage:export')")
    @Log(title = "笼位管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LmisCage lmisCage)
    {
        List<LmisCage> list = lmisCageService.selectLmisCageList(lmisCage);
        ExcelUtil<LmisCage> util = new ExcelUtil<LmisCage>(LmisCage.class);
        util.exportExcel(response, list, "笼位管理数据");
    }

    /**
     * 获取笼位管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('lmisCage:cage:query')")
    @GetMapping(value = "/{cageId}")
    public AjaxResult getInfo(@PathVariable("cageId") Long cageId)
    {
        return success(lmisCageService.selectLmisCageByCageId(cageId));
    }

    /**
     * 新增笼位管理
     */
    @PreAuthorize("@ss.hasPermi('lmisCage:cage:add')")
    @Log(title = "笼位管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LmisCage lmisCage)
    {
        return toAjax(lmisCageService.insertLmisCage(lmisCage));
    }

    /**
     * 修改笼位管理
     */
    @PreAuthorize("@ss.hasPermi('lmisCage:cage:edit')")
    @Log(title = "笼位管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LmisCage lmisCage)
    {
        return toAjax(lmisCageService.updateLmisCage(lmisCage));
    }

    /**
     * 删除笼位管理
     */
    @PreAuthorize("@ss.hasPermi('lmisCage:cage:remove')")
    @Log(title = "笼位管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cageIds}")
    public AjaxResult remove(@PathVariable Long[] cageIds)
    {
        return toAjax(lmisCageService.deleteLmisCageByCageIds(cageIds));
    }
}
